package com.qf.controller;


import com.qf.pojo.Degassing;
import com.qf.service.DegassingService;
import com.qf.utils.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/degassing")
@CrossOrigin
public class DegassingController {

    @Autowired
    DegassingService degassingService;

    @GetMapping("/findAll")
    public ResultMsg findAll(@RequestParam(required = false, defaultValue = "1")int current, @RequestParam(required = false, defaultValue = "20")int pageSize){
        return  degassingService.findAll(current,pageSize);
    }

    @GetMapping("/findOne")
    public ResultMsg findOne(int degassingId){
        return  degassingService.findOne(degassingId);
    }

    @GetMapping("/findAllByDate")
    public ResultMsg findAllByDate(String startTime, String endTime,@RequestParam(required = false, defaultValue = "1")Integer current, @RequestParam(required = false, defaultValue = "20")Integer pageSize){
        return  degassingService.findAllByDate(startTime,endTime,current,pageSize);
    }

    @PostMapping("/add")
    public ResultMsg add(@RequestBody Degassing degassing){
        return degassingService.add(degassing);
    }

    @PostMapping("/updateDegassing")
    public ResultMsg updateRecycle(@RequestBody Degassing degassing){
        return degassingService.updateDegassing(degassing );
    }

    @PostMapping("/delete")
    public ResultMsg delRecycle(@RequestBody Map<String,Object> map){
        return degassingService.delDegassing(map);
    }
}
